package com.orhon.smartcampus.modules.teacher.mm;

import java.util.List;

import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

import com.orhon.smartcampus.modules.base.mm.DictionaryMapper;
import com.orhon.smartcampus.modules.base.mm.LangMapper;
import com.orhon.smartcampus.modules.teacher.entity.Passport;
import com.orhon.smartcampus.modules.teacher.entity.PassportAudit;
import com.orhon.smartcampus.modules.teacher.gqlModel.GQLPassportAudit;

@Mapper(
        uses={
                LangMapper.class,
                DictionaryMapper.class
        }
)
public interface PassportAuditMapper {
    PassportAuditMapper MAPPER = Mappers.getMapper(PassportAuditMapper.class);
    @Mappings({
            @Mapping(source="id",target="id"),
            @Mapping(source="teacherPassportByPassportId",target="passport_id", qualifiedByName = "getPassportId"),
            @Mapping(source="compid",target="compid"),
            @Mapping(source="companyopinion",target="companyopinion"),
            @Mapping(source="directorcompanyopinion",target="directorcompanyopinion"),
            @Mapping(source="createdBy",target="created_by"),
            @Mapping(source="updatedBy",target="updated_by"),
            @Mapping(source="createdAt",target="created_at"),
            @Mapping(source="updatedAt",target="updated_at"),
            @Mapping(source="deletedAt",target="deleted_at"),
    })
    GQLPassportAudit mapEntity(PassportAudit entity);
    @InheritConfiguration(name = "mapEntity")
    List<GQLPassportAudit> mapEntityList(List<PassportAudit> entities);
    @Named("getPassportId")
    default Long getPassportId(Passport passport){
        if(passport!=null){
            return passport.getId();
        }
        return null;
    }
}
